a2c2fa08c9aaa66f8a6e3d5beead2529e93cdc41,modules/util/pmd/src/com/liferay/pmd/rules/junit/AssertFailJUnitRule.java,AssertFailJUnitRule,isAssertFailStatement,#ASTStatementExpression#,89

Before Change


	 * Tells if the expression is an assert.fail statement
	 */
	private boolean isAssertFailStatement(ASTStatementExpression expression) {
		if (expression!= null && expression.jjtGetNumChildren()>0 &&
			(expression.jjtGetChild(0) instanceof ASTPrimaryExpression)) {

			ASTPrimaryExpression astPrimaryExpression =
				(ASTPrimaryExpression)expression.jjtGetChild(0);

			if (astPrimaryExpression.jjtGetNumChildren()> 0 &&
				astPrimaryExpression.jjtGetChild(0)
					instanceof ASTPrimaryPrefix) {

				ASTPrimaryPrefix pp =
					(ASTPrimaryPrefix)astPrimaryExpression.jjtGetChild(0);

				if (pp.jjtGetNumChildren()>0 &&
					pp.jjtGetChild(0) instanceof ASTName) {

					String img = ((ASTName)pp.jjtGetChild(0)).getImage();

After Change


	private boolean isAssertFailStatement(
		ASTStatementExpression astStatementExpression) {

		if ((astStatementExpression == null) ||
			(astStatementExpression.jjtGetNumChildren() == 0)) {

			return false;
		}

		Node node = astStatementExpression.jjtGetChild(0);

		if (!(node instanceof ASTPrimaryExpression)) {
			return false;
		}

		ASTPrimaryExpression astPrimaryExpression = (ASTPrimaryExpression)node;

		if (astPrimaryExpression.jjtGetNumChildren() == 0) {
			return false;
		}

		node = astPrimaryExpression.jjtGetChild(0);

		if (!(node instanceof ASTPrimaryPrefix)) {
			return false;
		}

		ASTPrimaryPrefix astPrimaryPrefix = (ASTPrimaryPrefix)node;

		if (astPrimaryPrefix.jjtGetNumChildren() == 0) {
			return false;
		}

		node = astPrimaryPrefix.jjtGetChild(0);